package com.zis.system.client;

import com.alibaba.fastjson.JSONObject;
import com.zis.starter.core.ResponseEntity;
import com.zis.starter.core.SearchParams;
import com.zis.system.model.User;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Map;

@FeignClient("sys-server")
public interface UserClient {

    @RequestMapping(value = "/user/list", method = RequestMethod.POST)
    PageQuery<User> findByPage(@RequestBody SearchParams params) throws Exception;

    @RequestMapping(value = "/user/condition", method = RequestMethod.POST)
    ResponseEntity findByCondition(@RequestBody Map params) throws Exception;

    @RequestMapping(value = "/user/save", method = RequestMethod.POST)
    ResponseEntity insert(@RequestBody User model) throws Exception;

    @RequestMapping(value = "/user/update", method = RequestMethod.POST)
    ResponseEntity update(@RequestBody User model) throws Exception;

    @RequestMapping(value = "/user/delete/{id}", method = RequestMethod.GET)
    ResponseEntity delete(@PathVariable("id") String id) throws Exception;

    @RequestMapping(value = "/user/select/username/{loginName}", method = RequestMethod.GET)
    ResponseEntity findByLoginName(@PathVariable("loginName") String loginName) throws Exception;

    @RequestMapping(value = "/user/role/save", method = RequestMethod.POST)
    ResponseEntity userRoleSave(@RequestBody JSONObject params) throws Exception;

    @RequestMapping(value = "/user/select/role/{userId}", method = RequestMethod.GET)
    ResponseEntity findByUserId(@PathVariable("userId") String userId) throws Exception;
}
